home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-06-04 | 7.8 KB | 201 lines | [TEXT/MPS ] |
- Color Icon Dragging Code
-
- Files:
-
- The core functionality for the dragging of color icons is
- in two units: UOffscreenManager and UIconDragging. MNothing,
- UNothing, and UReliefGridView are used in the demonstration
- example only.
-
- Core Functionality-
-
- UOffscreenManager.p
- UOffscreenManager.inc1.p
- UIconDragging.p
- UIconDragging.inc1.p
-
- Example-
-
- MNothing.p
- UNothing.p
- UNothing.inc1.p
- UReliefGridView.p
- Nothing.r
- Color.r
- NothingResources.rsrc
- Nothing.MAMake
-
- Built Programs-
-
- Nothing (optimized version)
- Nothing.debug (debugging version)
-
- Miscellaneous-
-
- Read Me (this document)
-
-
- Quick Install:
-
- The Quick install procedure assumes you have OSImage but
- haven't installed it yet and you want to build the
- sample program right now, without going through the normal
- installation procedure.
-
- Copy the OSImage Pascal interfaces and library to the
- icon dragging folder, rename Nothing.MAMake to
- Nothing.MAMake.complex and Nothing.MAMake.simple to
- Nothing.MAMake. You may now build the sample program using
- MABuild.
-
-
- Installing:
-
- You'll need to acquire and install OSImage from the
- Donoho Design Group. This library is available from MADA. If
- you don't have OSImage you'll have to make some modifications
- to the source before it will work. Good Luck.
-
- Assuming you have OSImage and you've installed it in the
- conventional way you need to modify Nothing.MAMake to build
- the example "Nothing" application. You need to remove the
- OtherPascalOptions definition and replace {SCPBldgBlksDir},
- {SCPPLibraries}, and {SCPBldgBlksLib} in the OtherLinkFiles
- definition with {MALibraries}, {PLibraries}, and {OSImageLib},
- respectively.
-
- If you haven't installed OSImage conventionally (you may have
- combined it with other libraries or put the definitions and
- libraries in separate places) you need to set {SCPInterfaces}
- and {SCPBldgBlksDir} in the OtherPascalOptions definition to
- the directories that hold the UOSBitmap.p and UOSImage.p
- interfaces, respectively. In addition, {SCPLibraries} and
- {SCPBldgBlksDir} will have to be set to the directories that
- contain OSBitmap.o and OSImage library directories.
- {SCPBldgBlksLib} must be replaced by the library file that
- contains OSImage. Note that under many circumstances
- {SCPBldgBlksDir}, or its equivalent, will normally contain
- UOSImage.p, UOSImage.inc1.p, and the various directories that
- contain the differently configured builds of the library
- (e.g., 'Debug Files:', 'Non-Debug Files:', '.S6NmTeSm:', etc.)
-
-
- Features:
-
- 1) Works across multiple monitors with multiple screen depths.
-
- 2) Automatically adjusts when either color table or depth of
- the screen's GDevice changes. These characteristics are
- checked and adjusted in the background by cohandler every
- 1/2 second, so there should not normally be a perceptible
- delay when the user starts to drag. Also, the cohandler
- makes the right thing happen, even if the depths or colors
- were changed without switching in and out of the application
- (e.g., when an FKey like Switch-A-Roo™ is used).
-
- 3) Works with GC accelerator.
-
- 4) Works under System 7.0.
-
- 5) Works on Mac II-class machines.
-
-
- Known Problems:
-
- 1) No performance profile or optimizations have been performed.
- However, I feel fairly certain that constraining
- TCIconTracker.fScreenLocusRect such that the offscreen
- bitmaps are aligned will give much better performance.
- Other options include creating an TCIconTracker.fUnderIcon
- of the proper depth for each monitor- another offscreen
- manager, perhaps.
-
- 2) Turning on HS reveals some funny business in the offscreen
- image blitted to the screen, but only the first time through
- the loop. This has never caused a crash and has never
- been manifested with HS off.
-
- 3) There is no reason why this code should be restricted to
- color icons only.
-
- 4) The arrow cursor flickers, even when the mouse isn't moved.
- This is somewhat annoying.
-
- 5) Failure of ReallocOSImage in TOffscreenDevice.CheckDepthAndColor
- will cause the offscreen images to be of the wrong depth
- and therefore will produce "unusual" coloring effects
- when blitted to the screen. Preflighting the memory can
- solve this problem.
-
- 6) The code must be checked for proper failure handling.
-
- 7) Needs to be made to work on non-ColorQuickdraw systems that
- don't have color icons. Note: OSImage does the right thing
- on GWorld-capable and non-GWorld-capable systems (i.e., GWorlds
- are used if they are there, but they are not necessary).
-
- 8) The most serious problem is in TCIconTracker.Free where the code
- to free fMaxDepthGrafPort is commented out, which should cause
- memory leakage. Unfortunately, uncommenting this code causes
- the system to, eventually, crash when the icon is dropped on
- the desktop, rather than another view.
-
- How it works:
-
- Dragging icons is written in Object Pascal and uses MacApp 2.0.x.
- It works by maintaining preallocated offscreen pixmaps, using the
- OSImage package from Donoho Design Group, for each connected "real"
- GDevice which are combined to form a virtual composite pixmap using
- object abstractions.
-
- Essentially, the virtual pixmap mirrors the area of the user-visible
- screen around where the user is dragging the icon. Before plotting
- the color icon to the virtual pixmap, the area under where the "icon
- to be plotted" is saved in another offscreen pixmap. As the user
- drags the icon, the saved area under the icon is restored and the
- icon is plotted in the new location in the virtual pixmap, after the
- area under the new location is again saved. Then, the entire virtual
- pixmap is blasted to the screen, thereby avoiding video flicker.
-
- Dragging icons uses multiple offscreen pixmaps, one for each GDevice,
- for performance reasons, since each GDevice has its own color table
- and depth. Using one pixmap to mirror all GDevices would require
- QuickDraw to make adjustments for these differences when pixmaps are
- blitted between "incompatible" GDevices. This is very inefficient.
- Instead, each GDevice has its own compatible pixmap that is used when
- the area around the icon intersects that GDevice. The virtual
- pixmap abstraction (TOffscreenManager) handles the usage of these
- multiple pixmaps transparently.
-
- One can see the interaction between the GDevice offscreen pixmaps,
- the virtual pixmap, and the pixmap that is saved under the icon
- by running the debug version of "Nothing" and turning on intense
- debugging in the MacApp debugger. What you will see is that each
- GDevice will continuously plot its contents in the lower right-hand
- corner of its monitor. At the upper-left of the (0,0) origin monitor
- you will see the composite pixmap plotted, and below that you will see
- the screen contents under the icon.
-
- Another aspect of the usage of offscreen pixmaps of limited size
- in an application such as this is the requirement that as the
- offscreen pixmap moves to mirror a new location of the screen it
- must not move so far as to preclude the restoration of the screen
- where the icon WAS. That is, the size of the offscreen pixmap
- must encompass the extent of where the icon WAS and where it
- WILL BE in order to erase the old one and plot the new one at
- the same time. But, since the user can move the cursor arbitrarily
- fast it becomes necessary to constrain the movement of the offscreen
- pixmap, and therefore the icon itself. Therefore if the user
- moves the cursor very fast he will notice that the icon will lag
- behind his cursor.
-
- Dragging icons also handles most of the tedium of making MacApp
- views aware when an icon is dragged onto it from another view.
- The code is somewhat messy and involves some tricks in the use
- of view focusing but essentially does a FindWindow converts the
- result to a MacApp window and recursively descends the view
- hierarchy to the topmost view. (Many thanks to Richard Rodseth
- for sample code on how to do this.)
-
-
- Geoff Pascoe 4/8/91, 5/23/91, 5/31/91